package baseFx.database;

import baseFx.common.Dynamic;

import java.util.List;

public interface MultipleReader extends AutoCloseable {
    <T> List<T> read(Class<T> clazz);

    default <T> T readOne(Class<T> clazz) {
        List<T> items = read(clazz);
        if (items != null && items.size() > 0) {
            return items.get(0);
        }
        return null;
    }

    default Dynamic readOne() {
        return readOne(Dynamic.class);
    }

    default List<Dynamic> read() {
        return read(Dynamic.class);
    }

    @Override
    void close();
}
